package com.api.server.controller;


import com.api.server.pojo.*;
import com.api.server.service.IOrderService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author shi
 * @since 2022-04-28
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private IOrderService orderService;

    //根据订单id查询订单信息
    @ApiOperation(value = "根据订单id查询订单信息")
    @PostMapping("/message")
    public RespBean message(String ordernumber){
        Order order = orderService.message(ordernumber);
        return Result.success("获取订单信息成功！",order);
    }


    //增加订单
    @ApiOperation(value = "增加订单")
    @PostMapping
    public Result add(@RequestBody Order order){
        orderService.add(order);
        return Result.success(201,"订单信息创建成功",order);
    }



    //根据订单 租用设施类型/设施编号/处理状态/下单用户身份证号/完成状态 查看维护信息列表
    @ApiOperation(value = "根据订单 租用设施类型/设施编号/处理状态/下单用户身份证号/完成状态 查看维护信息列表")
    @GetMapping("/orders")
    public RespBean venues(UserListPage userListPage){
        Map<String,Object> map = orderService.page(userListPage);
        return Result.success("获取订单信息列表成功！",map);
    }

}
